//
//  XYMainViewCell.m
//  十年少
//
//  Created by 尧的mac on 15/11/28.
//  Copyright © 2015年 xxy.icom. All rights reserved.
//

#import "XYMainViewCell.h"
#import "XYMainModel.h"
#import "XYMainFrom.h"
@interface XYMainViewCell ()
@property(nonatomic,weak)UIView *spcView;
@property(nonatomic,weak)UIView *footView;

@property(nonatomic,weak)UILabel *timeName;
@end
@implementation XYMainViewCell
+(instancetype)mainCell:(UITableView *)tableView{
    
    XYMainViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (cell ==nil) {
        cell = [[XYMainViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //标题
        UILabel *titleName  =[[UILabel alloc]init];
        titleName.textColor = [UIColor blackColor];
        titleName.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:titleName];
        self.titleName = titleName;

        
      
        //分隔线
        UIView *spcView = [[UIView alloc]init];
        spcView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:spcView];
        self.spcView = spcView;
        //正文
        UILabel *textName  =[[UILabel alloc]init];
        textName.textColor = [UIColor blackColor];
        textName.font = [UIFont systemFontOfSize:15];
        textName.numberOfLines = 0;
        textName.backgroundColor = [UIColor colorWithRed:120/255.0 green:64/255.0 blue:54/255.0 alpha:1.0];
        [self.contentView addSubview:textName];
        self.textName = textName;
        
        
        //时间
        UILabel *timeName  =[[UILabel alloc]init];
        timeName.textColor = [UIColor grayColor];
        timeName.font = [UIFont systemFontOfSize:12];
        timeName.textAlignment =NSTextAlignmentRight;
        [self.contentView addSubview:timeName];
        self.timeName = timeName;
        
        //尾部分割线
        UIView *footView = [[UIView alloc]init];
        footView.backgroundColor = [UIColor blackColor];
        [self.contentView addSubview:footView];
        self.footView = footView;
        
        
        
    }
    return self;
}


-(void)setMainFrom:(XYMainFrom *)mainFrom{
    
    
    _mainFrom = mainFrom;
    
    [self setFrom];
}
-(void)setFrom{
    
    XYMainModel * mainModel =  self.mainFrom.mainModel;

    //标题
    self.titleName.frame = self.mainFrom.titleFrom;
    self.titleName.text = mainModel.title;

//    //分割线
    self.spcView.frame = self.mainFrom.viewFrom;
    
//    //正文
    self.textName.frame =self.mainFrom.textFrom;
    self.textName.text = mainModel.text;
    
    //时间
    self.timeName.frame = self.mainFrom.ctFrom;
    self.timeName.text = mainModel.ct;
    
     //尾部分割线
    
    self.footView.frame = self.mainFrom.footFrom;
}

@end
